<%@ page contentType= "text/html;charset=utf-8" %>
<%@ include file="../common/base.jsp" %>

<div id="header">
	<img width="76" height="57" src="<%=request.getContextPath() %>/img/logo.png" alt="<fmt:message key='Optiworks' />">&nbsp;

	<fmt:message key="OPTMS" />
	&nbsp;&nbsp;
	<font size="3">v0.9</font>
	

	<div id="div_lang" style="float:right;font-size:12px;margin-top:40px;margin-right:10px;" >
		<a href="javascript:setPreLocale('en_EN')">English</a> | <a href="javascript:setPreLocale('zh_CN')">中文</a>
	</div>
</div>

<script language="javascript">
function setPreLocale(locale){
	setCookie("preferLocale",locale);
	window.location.reload();
}

function hideMenu(){
	var cookie = getCookie("hideMenu");
	if(cookie != null){
		delCookie("hideMenu");
	}
	setCookie("hideMenu", "true");
	var menu = document.getElementById("leftside");
	var content = document.getElementById("rightside");
	var hma = document.getElementById("hma");
	var sma = document.getElementById("sma");
	menu.style.display = "none";
	//enlarge(860);
	content.style.width = "960px";
	hma.style.display = "none";
	sma.style.display = "block";
}

function enlarge(width){
	var cur = document.getElementById('rightside').style.width;
	if(cur == '960px'){
		return;
	}
	document.getElementById('rightside').style.width = width + "px";
	if(width == '960'){
		return;
	}
	setTimeout("enlarge(Number(document.getElementById('rightside').style.width.substr(0,3))+2)",1);
}

function deflate(width){
	var cur = document.getElementById('rightside').style.width;
	if(cur == '' || cur == '860px'){
		return;
	}
	document.getElementById('rightside').style.width = width + "px";
	if(width == '860'){
		menu = document.getElementById("leftside").style.display = "block";
		return;
	}
	setTimeout("deflate(Number(document.getElementById('rightside').style.width.substr(0,3))-2)",1);
}

function showMenu(){
	var cookie = getCookie("hideMenu");
	if(cookie != null){
		delCookie("hideMenu");
	}
	setCookie("hideMenu", "false");
	var menu = document.getElementById("leftside");
	var content = document.getElementById("rightside");
	var hma = document.getElementById("hma");
	var sma = document.getElementById("sma");
	//deflate(960);
	menu.style.display = "block";
	content.style.width = "860px";
	hma.style.display = "block";
	sma.style.display = "none";
}

function setCookie(name,value){
    var Days = 3650;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";path=/;expires=" + exp.toGMTString();
}

function getCookie(name){
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}

function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";path=/;expires="+exp.toGMTString();
}

function warnFailedStep(){
	var cells = new Array();

	<% 
		Object obj = request.getAttribute("failedCells"); 
		if(obj != null){
			String[] strs = (String[])obj; 
			for(int i = 0; i < strs.length; i++){
	%>
				cells[<%=i%>] = "<%=strs[i]%>";
	<%
			}		
		}
	%>
	for (var i = 0; i < cells.length; i++){
    	var input = document.getElementsByName(cells[i]);
		for (var j = 0; j < input.length; j++){
	        if (input[j].type == "text"){
	           input[j].style.background = "red";
	        }
		}
	}
}
</script>